package com.zbkj.crmeb.store.model;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.zbkj.crmeb.plat.by.dto.ByCommonConstant;
import com.zbkj.crmeb.store.FeatureBaseDO;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.time.LocalDateTime;
import java.util.Date;

@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("eb_store_product_log")
public class StoreProductLog extends FeatureBaseDO {
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;
    private Date gmtCreate;
    private Date gmtModified;
    private String businessCode;
    private String creator;
    private String businessType;
    private Date operateTime;
    private String code;
    private String content;
    private String feature;

    @Override
    protected void resetFeature() {
        feature = JSONObject.toJSONString(getFeatureMap());
    }

    @Override
    protected String getFeatureString() {
        return feature;
    }

    public static StoreProductLog assembledLog(String businessCode,String creator,String businessType,String code,String content){
        StoreProductLog storeProductLog = new StoreProductLog();
        storeProductLog.setGmtModified(new Date());
        storeProductLog.setGmtCreate(new Date());
        storeProductLog.setBusinessCode(businessCode);
        storeProductLog.setCreator(creator);
        storeProductLog.setBusinessType(businessType);
        storeProductLog.setOperateTime(new Date());
        storeProductLog.setCode(code);
        storeProductLog.setCode(content);
        return storeProductLog;
    }

    public static StoreProductLog assembledLog(String businessCode, String businessType, String content) {
        return assembledLog(businessCode, "SYS", businessType, businessCode, content);
    }

    public static StoreProductLog assembledLog(String businessCode, String content) {
        return assembledLog(businessCode, "SYS", ByCommonConstant.BY_PLAT_PUSH_LOG, businessCode, content);
    }
}